package com.dingding.common.quartz;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.dingding.common.reset.activity.service.IResetInvalidActivityService;
import com.dingding.common.reset.sign.service.IResetSignService;
import com.dingding.facade.user.facade.special.driver.ISpecialUserInfoFacade;
import com.dingding.facade.user.facade.tailwind.ITailwindUserInfoFacade;
import com.dingding.facade.user.service.car.ICarBrandModelFacade;
import com.dingding.order.service.IUserOrderFacade;

/**
 * @ClassName: DingDingQuartzJob
 * @Description: 触发器执行类
 * @author yuHaiQing
 * @date 2016年4月8日 下午5:11:31
 */
@Component("quartzJob")
public class DingDingQuartzJob{

	private static final Logger log = Logger.getLogger(DingDingQuartzJob.class);
	
	//每日签到Service接口
	@Resource(name="resetSignService")
	private IResetSignService resetSignService;
	
	//活动服务接口
	@Resource(name="resetInvalidActivityService")
	private IResetInvalidActivityService resetInvalidActivityService;
	
	//订单服务接口
	@Resource(name="userOrderFacade1")
	private IUserOrderFacade userOrderFacade;
	
	@Resource(name = "carBrandModelFacade")
	private ICarBrandModelFacade carBrandModelFacade;
	
	@Resource(name = "specialUserAccountFacade_special")
	private ISpecialUserInfoFacade specialUserInfoFacade;
	
	@Resource(name = "tailwindUserInfoFacade_Tailwind")
	private ITailwindUserInfoFacade tailwindUserInfoFacade;
	
	/**
	 * 
	 * @Title: reset
	 * @Description:重置用户签到
	 * @author cheshaowei
	 * @throws
	 */
	public void reset(){
		
		log.info("执行重置每日用户签到！");
		resetSignService.resetAttendActivity();
		
		log.info("重置活动是否有效");
		resetInvalidActivityService.resetInvalidActivity();
		
		// 重置专车用户提现次数
		log.info("重置专车用户提现次数");
		specialUserInfoFacade.resetSpecialDepositNumber();
		
		// 重置顺风车用户提现次数
		log.info("重置顺风车用户提现次数");
		tailwindUserInfoFacade.resetTailwindDepositNumber();
	}

	/**
	 * 
	 * @Title: orderTimingTask 
	 * @Description: 订单定时任务 
	 * @author YHQ 
	 * @return void    返回类型
	 * 
	 */
	public void orderTimingTask(){
	
		log.info("--------自动确认到达---------");
		userOrderFacade.autoConfirmArrive();
		
		log.info("----------自动取消订单--------");
		userOrderFacade.autoCancelOrder();
		
		log.info("----------自动取消出租车订单--------");
		userOrderFacade.autoCancelTaxiOrder();
		
		log.info("----------自动取消专车订单--------");
		userOrderFacade.autoCancelSpecialOrder();
		
	}
	
	
	/**
	 * @Description:自动同步订单
	 * @author fengshuonan
	 * @since 2.3.2
	 */
	public void syncOrder(){
		log.info("------------开始同步订单------------");
		this.userOrderFacade.syncOrder();
	}
	
	/**
	 * @Description:获取当下的所有的车辆品牌到数据库
	 * @author fengshuonan
	 * @since 2.4
	 */
	public void fetchCarInfo(){
		log.info("------------开始同步车辆的品牌和型号------------");
		this.carBrandModelFacade.fetchToDb();
	}
}
